package com.kk.hellospringbootstarter.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: springboot-autoconfig
 * @description:
 * @author: Mr.Dai
 * @create: 2020-03-02 16:34
 **/
@EnableConfigurationProperties({PersonProperties.class})
@ConditionalOnClass(PersonService.class)
@Configuration
public class PersonServiceAutoConfiguration {

    @Autowired
    private PersonProperties personProperties;

    @Bean
    @ConditionalOnMissingBean(PersonService.class)
    public PersonService getPersonService(){
        return new PersonService().setPersonProperties(personProperties);
    }
}
